package com.example.day7;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

public class Main2Activity extends AppCompatActivity {
    private int dsec=3;
    private Handler handler=new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(@NonNull Message message) {
            if (message.what==0){
                dsec--;
                if (dsec>0){
                    handler.sendEmptyMessageDelayed(0,1000);
                }else if (dsec==0){
                    startActivity(new Intent(Main2Activity.this,HomeActivity.class));
                }
            }
            return false;
        }
    });
    private TextView mText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initViews();
    }

    private void initViews() {
        mText = findViewById(R.id.text);
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.anim);
        mText.setAnimation(animation);
        handler.obtainMessage();
        handler.sendEmptyMessage(0);
    }
}
